<template>
    <art-table :data="props.simulatedExam" :loading="tableLoading" :currentPage="pageNum" :pageSize="pageSize"
        :total="pageTotal" @current-change="currentChange" @size-change="sizeChange">
        <template #default>
            <el-table-column label="学习时间" prop="startTime" align="center" />
            <el-table-column label="科目" prop="categoryId" align="center" #default="scope">
                {{ categoryList[scope.row.categoryId] }}
            </el-table-column>
            <el-table-column label="车型" prop="carModelId" align="center" #default="scope">
                {{ carTypeList[scope.row.carModelId] }}
            </el-table-column>
            <el-table-column label="练习试卷" prop="xlsj" align="center">
                模拟考试
            </el-table-column>
            <el-table-column label="用时" prop="time" align="center" #default="scope">
                {{ formatDurationToMinSec(2700 - scope.row.duration) }}
            </el-table-column>
            <el-table-column label="答卷分数" prop="score" align="center" />
            <el-table-column label="正确" prop="correctQuestions" align="center" />
            <el-table-column label="错误" prop="falseNum" align="center" #default="scope">
                {{ scope.row.totalQuestions - scope.row.correctQuestions }}
            </el-table-column>
        </template>
    </art-table>
</template>
<script setup lang="ts">
import { ACCOUNT_TABLE_DATA } from '@/mock/temp/formData_userlist'
import { FormInstance } from 'element-plus'
import { ElMessageBox, ElMessage } from 'element-plus'
import type { FormRules } from 'element-plus'

const props = defineProps({
    simulatedExam: Array,
    default: []
})

const tableLoading = ref(false)
const pageNum = ref(1)
const pageSize = ref(10)
const pageTotal = ref(0)
const carTypeList = ref<any>({
    '1': '小车（C1,C2,C3）',
    '2': '货车（A2,B2）',
    '3': '客车（A1,A3,B1）',
    '5': '轻型牵引挂车（C6）',
    '8': '摩托车（D,E,F）'
})
const categoryList = ref<any>({
    1: '科目一',
    2: '科目二',
    3: '科目三',
    4: '科目四',
    5: '注销恢复',
    6: '满分学习',
    7: '三力测试'
})

// async function getData() {
//     try {
//         tableLoading.value = true
//         const { code, data } = await userList({
//             pageNum: pageNum.value,
//             pageSize: pageSize.value,
//             queryStartTime: searchForm.creatStartTime ? formatDate(searchForm.creatStartTime) : '',
//             queryEndTime: searchForm.creatEndTime ? formatDate(searchForm.creatEndTime) : '',
//             queryName: searchForm.name,
//             queryMobile: searchForm.phone,
//             queryGender: searchForm.sex,
//             queryIsVip: searchForm.level,
//             queryStartActiveTime: searchForm.activeStartTime ? formatDate(searchForm.activeStartTime) : '',
//             queryEndActiveTime: searchForm.activeEndTime ? formatDate(searchForm.activeEndTime) : ''
//         })
//         if (code === '00000' && data) {
//             tableData.value = data.list
//             pageTotal.value = data.total

//             console.log(tableData.value, 'tableData.value')
//         }
//     } catch (e) {
//     } finally {
//         tableLoading.value = false
//     }
// }

function formatDurationToMinSec(seconds: number): string {
    if (typeof seconds !== 'number' || isNaN(seconds) || seconds < 0) return '0分0秒'
    const min = Math.floor(seconds / 60)
    const sec = Math.floor(seconds % 60)
    return `${min}分${sec}秒`
}

const currentChange = (val: number) => {
    pageNum.value = val
    // getData()
}

const sizeChange = (val: number) => {
    pageSize.value = val
    pageNum.value = 1
    // getData()
}
</script>
<style scoped lang="scss"></style>